# import torch
# import cv2
# import os
# import time
#
# from utils.utils import DetecteOneImage,get_classes
# from utils.deepsort import DeepSort
# import configuration as cfg
# from utils.draw import draw_boxes
#
# class VideoTracker(object):
#     def __init__(self):
#         self.init_object()
#
#     def init_object(self):
#         #========================创建cv窗口对象==================================
#         if cfg.display:
#             cv2.namedWindow("test", cv2.WINDOW_NORMAL)
#             cv2.resizeWindow("test", cfg.display_width, cfg.display_height)
#         #===============================创建对象==============================
#         self.video = cv2.VideoCapture()   #创建一个视频捕捉类
#         self.detectOneImage = DetecteOneImage()    #目标检测后处理类
#         #========================创建一个deepsort对象，这个跟踪器与yolov4无关=============================
#         self.deepsort = DeepSort()
#         #+======================类别=============================
#         self.classes,self.classes_numbers = get_classes(cfg.classes_path)
#
#     def __enter__(self):
#         assert os.path.isfile(cfg.video_path), "Error: VIDEO_PATH path error"
#         self.video.open(cfg.video_path)
#         self.im_width = int(self.video.get(cv2.CAP_PROP_FRAME_WIDTH))
#         self.im_height = int(self.video.get(cv2.CAP_PROP_FRAME_HEIGHT))
#
#         if cfg.save_path and os.path.isdir(cfg.save_path):
#             fourcc = cv2.VideoWriter_fourcc(*'MJPG')
#             self.writer = cv2.VideoWriter(cfg.save_path, fourcc, 20, (self.im_width, self.im_height))
#
#         assert self.video.isOpened()
#         return self
#
#     def __exit__(self, exc_type, exc_value, exc_traceback):
#         if exc_type:
#             print(exc_type, exc_value, exc_traceback)
#
#     def run(self):
#         idx_frame = 0   #表示第几帧
#         while self.video.grab():  #从视频里面抓取下一帧
#             idx_frame += 1
#             if idx_frame % cfg.frame_interval:#如果不为0,如果frame_interval=1，表示每帧都用来推理，为2表示每隔一帧进行推理，依次类推
#                 continue
#
#             start = time.time()#计时
#             #===============单个视频帧处理=================
#             _, ori_im = self.video.retrieve() #返回解码后的视频帧
#             boxes = self.detectOneImage.detect_one_image(ori_im)#boxes是对应的object的bbox的坐标，当前图片帧里有多少个目标=len(boxes)
#             if len(boxes)==0:
#                 continue
#             boxes = torch.tensor(boxes)
#             bbox_xywh = boxes[:, :4] #bbox坐标,格式为center_x,center_y,box_w,box_h
#             cls_conf = boxes[:,5]*boxes[:,4]  #类别的置信度
#             class_ids = boxes[:,6] #类别id
#
#             # cls_id = int(cls_id.numpy()[0])
#             # if cls_id != 2:
#             #     continue
#             # select person class
#             # mask = cls_ids==2
#             # bbox_xywh = bbox_xywh[mask]
#             bbox_xywh[:, 3:] *= 1.2  # 将bbox扩大一点点，以防止bbox太小
#             # cls_conf = cls_conf[mask]
#             #===================进行跟踪=========================
#             outputs = self.deepsort.update(bbox_xywh, cls_conf, ori_im,class_ids)
#             #=================绘画bbox，可视化=====================
#             if len(outputs) > 0:
#                 bbox_xyxy = outputs[:, :4]
#                 identities = outputs[:,-2]
#                 classes_str = [self.classes[id] for id in outputs[:, -1]]
#                 ori_im = draw_boxes(ori_im,bbox_xyxy,identities,classes_str)
#
#             end = time.time()
#             print("One Image spend time: {:.03f}s, fps: {:.03f}".format(end - start, 1 / (end - start)))
#
#             if cfg.display:
#                 cv2.imshow("test", ori_im)
#                 cv2.waitKey(1)
#
#             if cfg.save_path and os.path.isdir(cfg.save_path):
#                 self.writer.write(ori_im)
#
# if __name__ == '__main__':
#     #====================创建和使用视频跟踪器类==================
#     with VideoTracker() as video_track:
#         video_track.run()


if __name__=="__main__":
    nums = [8,8,7,7,7]
    count = 1
    only = nums[0]
    for i in range(1,len(nums)):
        if count == 0:
            count = 1
            only = nums[i]
        elif only == nums[i]:
            count += 1
        else:
            count -= 1
    print(only)